package com.iweb.manager.controller;

import com.iweb.manager.model.tickets;
import com.iweb.manager.service.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/ticket")
public class TicketController {
    @Autowired
    TicketService ticketService;
    @GetMapping
    public List<tickets> queryAll(){
        System.out.println("查询全部");
        return ticketService.queryAll();
    }
    @GetMapping("/{show_id}")
    public List<tickets> queryByShowId(@PathVariable int show_id){
        System.out.println("查询指定演出票");
        return ticketService.queryByShowId(show_id);
    }
    @PostMapping
    int addOne(@ModelAttribute tickets tickets){
        System.out.println("增加一条");
        return ticketService.addOne(tickets);
    }
    @DeleteMapping
    int deleteOne(@RequestParam int ticket_id){
        System.out.println("删除一条");
        return ticketService.deleteOne(ticket_id);
    }
    @PutMapping
    int editOne(tickets tickets){
        System.out.println("修改一条");
        return ticketService.editOne(tickets);
    }
}
